package cn.soulfire.travel.service.impl;

import cn.soulfire.travel.constants.CommentConstant;
import cn.soulfire.travel.domain.Comment;
import cn.soulfire.travel.mapper.CommentMapper;
import cn.soulfire.travel.service.ICommentService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ma.rui.kai
 * @since 2020-10-13
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentMapper, Comment> implements ICommentService {
    @Autowired
    private CommentMapper commentMapper;

    @Override
    //如果是禁用或者启用
    public void disable(Comment comment) {
        if (comment.getState().equals(CommentConstant.COMMENT_ENABLE)) {
            comment.setState(CommentConstant.COMMENT_DISABLE);
            commentMapper.updateById(comment);
        } else {
            if (comment.getState().equals(CommentConstant.COMMENT_DISABLE)) {
                comment.setState(CommentConstant.COMMENT_ENABLE);
                commentMapper.updateById(comment);
            }
        }
    }
}

